package com.lizhenhua.usercheck.service.impl;

import com.lizhenhua.fmmall.entity.Users;

import com.lizhenhua.usercheck.mapper.UserCheckMapper;
import com.lizhenhua.usercheck.service.UserCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class UserCheckServiceImpl implements UserCheckService {
    @Autowired
    private UserCheckMapper checkMapper;

    @Override
    public Users queryUser(String userName) {
        Example example = new Example(Users.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("username", userName);
        List<Users> usersList = checkMapper.selectByExample(example);
        if (usersList.size() > 0) {
            return usersList.get(0);
        } else {
            return null;
        }
    }
}
